package com.ruoyi.project.system.memberdepartment.service.impl;

import com.ruoyi.common.utils.text.Convert;
import com.ruoyi.project.system.memberdepartment.domain.MemberDepartment;
import com.ruoyi.project.system.memberdepartment.mapper.MemberDepartmentMapper;
import com.ruoyi.project.system.memberdepartment.service.IMemberDepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.UUID;

/**
 * 申请捆绑企业部门Service业务层处理
 *
 * @author LCL
 * @date 2022-01-04
 */
@Service
public class MemberDepartmentServiceImpl implements IMemberDepartmentService
{
    @Autowired
    private MemberDepartmentMapper memberDepartmentMapper;

    /**
     * 查询申请捆绑企业部门
     *
     * @param id 申请捆绑企业部门ID
     * @return 申请捆绑企业部门
     */
    @Override
    public MemberDepartment selectMemberDepartmentById(String id)
    {
        return memberDepartmentMapper.selectMemberDepartmentById(id);
    }

    /**
     * 查询申请捆绑企业部门列表
     *
     * @param memberDepartment 申请捆绑企业部门
     * @return 申请捆绑企业部门
     */
    @Override
    public List<MemberDepartment> selectMemberDepartmentList(MemberDepartment memberDepartment)
    {
        return memberDepartmentMapper.selectMemberDepartmentList(memberDepartment);
    }

    /**
     * 新增申请捆绑企业部门
     *
     * @param memberDepartment 申请捆绑企业部门
     * @return 结果
     */
    @Override
    public int insertMemberDepartment(MemberDepartment memberDepartment)
    {
        memberDepartment.setId(UUID.randomUUID().toString().replace("-",""));
        memberDepartment.setCreatedTime(new Date());
        memberDepartment.setDelFlag(0);
        return memberDepartmentMapper.insertMemberDepartment(memberDepartment);
    }

    /**
     * 修改申请捆绑企业部门
     *
     * @param memberDepartment 申请捆绑企业部门
     * @return 结果
     */
    @Override
    public int updateMemberDepartment(MemberDepartment memberDepartment)
    {
        return memberDepartmentMapper.updateMemberDepartment(memberDepartment);
    }

    /**
     * 删除申请捆绑企业部门对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteMemberDepartmentByIds(String ids)
    {
        return memberDepartmentMapper.deleteMemberDepartmentByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除申请捆绑企业部门信息
     *
     * @param id 申请捆绑企业部门ID
     * @return 结果
     */
    @Override
    public int deleteMemberDepartmentById(String id)
    {
        return memberDepartmentMapper.deleteMemberDepartmentById(id);
    }

    @Override
    public List<MemberDepartment> queryAll() {
        return memberDepartmentMapper.queryAll();
    }
}
